<html><head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>物品损耗统计</title>
<#assign base=request.contextPath  />
    <link rel="stylesheet" href="${base}/js/layui/css/layui.css" media="all">
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
    <style type="text/css">
        .kcsy{
            width:280px;
            margin: 0;
            border: solid 2px #FFA500;
            border-radius: 10px;
            position: absolute;
            left: 30%;
            bottom: 30%;
            background: white;
            line-height: 40px;
            margin-left: 10px;
            display: none;
            font-size:16px;
        }
        button{
            border-radius: 10px  10px  10px  10px;
        }
    </style>
</head>

<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>物品损耗统计</legend>
</fieldset>

<table class="layui-hide" id="kcsy" lay-filter="user"></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">库存不足</a>
</script>
<div class="kcsy">
    <div style="width: 280px;" >
        <button class="layui-btn layui-btn-warm" type="button" style="font-weight: bold;font-size: 16px; width: 280px;">库存剩余</button>
    </div>
</div>
<script src="${base}/js/jquery.min.js"></script>
<script src="${base}/js/layui/layui.js"></script>
<script>
    $(".a2").click(function(){
        $(".kcsy").show(200)
    })

    layui.use('table', function(){
        var table = layui.table;

        table.render({
            elem: '#kcsy'
            ,url: '${base}/loss/list'
            ,cols: [[
                {field:'id', templet:function(val){
                    return val.LAY_INDEX
                }, title: '序号',align:'center'}
                ,{field:'itemName',title: '物品名称',align:'center'}
                ,{field:'lossNum', title: '损耗数', templet:function(val){
                     if(val.flag==1){
                   return  "多出"+toDecimal2(val.lossNum)
                     }
                   if(val.flag==2){
                     return  "损耗"+toDecimal2(val.lossNum)
                     }
                      if(val.flag==3){
                     return  "无损耗或多出，数量为："+toDecimal2(val.lossNum)
                     }
                     return "暂无";

                          },align:'center'}
                ,{field:'specifications', title: '规格',align:'center'}
                ,{field:'date', title: '统计日期',templet:function(val){
                    return changeDateFormat(val.date);
                },align:'center'}
            ]]
            ,id: 'testReload'
            ,height:'600'
            ,page: {
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                ,theme: '#0092EF'
            }
            ,done: function(res, curr, count){
                this.where={};
            }
        });
    });
    // 总价 强制保留两位小数
    function toDecimal2(x) {  
         var f = parseFloat(x); 
           if (isNaN(f)) {  
            return false;      
       }    
         var f = Math.round(x*100)/100; 
             var s = f.toString(); 
             var rs = s.indexOf('.');  
            if (rs < 0) {    
             rs = s.length;    
              s += '.';  
               }    
             while (s.length <= rs + 2) {  
                 s += '0';  
               }      
            return s;  
              } 

</script>

</body>
</html>